package com.rongda.deploy.operation.deploy.controller.body;

import com.rongda.deploy.operation.deploy.dto.R;
import com.rongda.deploy.operation.deploy.service.DServerService;
import com.rongda.deploy.operation.deploy.service.DeployService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Create By WeiBin on 2020/10/26 9:06
 *
 * @author WB
 */
@RestController
@AllArgsConstructor
@RequestMapping("deploy")
public class DeployController {

    private DeployService deployService;
    private DServerService dServerService;

    @GetMapping("/test")
    public R testConnect(Long serverDeployId) {
        return new R<>(this.deployService.testConnect(dServerService.queryById(serverDeployId)));
    }

    @GetMapping("/execute")
    public R executeCommend(String commend, Long serverDeployId) {
        return new R<>(this.deployService.executeCommend(commend, dServerService.queryById(serverDeployId)));
    }
}
